<?php
	include "./utils/auth.php";
	if(!(isset($_GET["paid"])))
	{
		die();
	}
?>



<div id="unpaidbattlesdiv" class="centercontainer">
	<div class="centercontainerheader">
		<?php if($_GET["paid"]==0) {echo "<h1>Unpayed Clanwars</h1>";} else {echo "<h1>Clanwars History</h1>";} ?>
	</div>
	
	<div class="centercontaineritem">
		<div id="battlestable" name="battlestable">
			<table width="100%">
				<thead>
					<tr>
						<td>ChannelID</td>
						<td>Map</td>
						<td>Enemy</td>
						<td>Time</td>
					</tr>
				</thead>
				<tbody>
<?php //SELECT bbbk from fwjnfj where id  IN (Select distinct 
/*	$stmt = $db->prepare("SELECT DISTINCT channelid, map, enemy, timestamp AS ts
FROM wottools.wotcwchannel
WHERE payedout = ? 
ORDER BY timestamp DESC");*/

	$stmt = $db->prepare("SELECT DISTINCT channelid, map, enemy, timestamp AS ts
	FROM wottools.wotcwchannel
	WHERE payedout = ? 
	ORDER BY timestamp DESC");
	$stmt->bind_param("i",$_GET["paid"]);
	$stmt->execute();

	$stmt->bind_result($channelid,$map,$enemy,$timestamp);
	while($stmt->fetch())
	{
		//echo $timestamp."<p>";
			echo '<tr>';
			echo '<td width="10%"><a href="javascript:getselectedpendingbattle('.$channelid.')">';
			echo $channelid;
			echo '</a></td>';
			echo '<td width="10%">';
			echo $map;
			echo '</td>';
			echo '<td width="40%">';
			echo $enemy;
			echo '</td>';
			echo '<td width="20%">';
			echo $timestamp;
			echo '</td>';
			echo '</tr>';
	}
	$stmt->close();

  ?>
				</tbody>
			</table>
		</div>
		
		<div id="currentbattle" name="currentbattle" class="currentbattle">
		</div>
	</div>
</div>

<div id="currentbattlecontainer" class="centercontainer">
</div>

<?php

?>